﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Animation;
using MapLibrary.Players;
using Microsoft.Xna.Framework;

namespace MapLibrary.Enemies
{
    class HookableObject : Sprite
    {

        public bool IsHooked { get; set; }

        public HookableObject()
        {
            Hookable = true;
            IsHooked = false;
        }

        public override void Update()
        {
            base.Update();
            if (!IsHooked)
            {
                Vector2 vel = Body.LinearVelocity;
                if (vel.Y < 0.01f)
                {
                    Body.IsStatic = true;
                }
            }
            else
            {
                Body.IsStatic = false;
            }
        }

        public override bool MyOnCollision(FarseerPhysics.Dynamics.Fixture f1, FarseerPhysics.Dynamics.Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            Player p = f2.Body.UserData as Player;
            if (p != null)
            {
                Vector2 vel = p.Body.LinearVelocity;
                if (vel.Y > 0)
                {
                    p.NumberJumps = 0;
                    p.EnterStateWithProperDirection("Landing");
                }
            }

            return true;
        }
    }
}
